-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\mdnieman\Dropbox\Mark Research\Published Work\2015\SPPO\PA Final Submission\Civil War Replication\fearon_laitin_rep.log
  log type:  text
 opened on:  11 Jan 2015, 17:09:48

. /*******************************/
> /*****  Mark David Nieman  *****/
> /*****  11/3/2013          *****/
> /*****  Empirical Replication*****/
> /*****  Stata 12.1         *****/
> /*******************************/
> #delimit;
delimiter now ;
. clear;

. clear matrix;

. clear mata;

. set memory 4g;

. program drop _all;

. set seed 17;

.         use Fearon_Laitin_2003.dta, replace;
(replication data for Fearon and Laitin, APSR 2003)

.                 /* Program Strategic Probit with Partial Observability estimator */
>                 #delimit;
delimiter now ;
.                 program define sppo_lf, rclass;
  1.                                                 args lnf r_det r_war r_acq g_war;
  2.                                                                         tempvar pun chal;
  3.                                 quietly gen double `pun' = normal(`g_war'/sqrt(2));
  4.                                                         quietly gen double `chal' = normal((`pun'*`r_war' + (1-`pun')*`r_acq'-`r_det')/(sqrt(`pun'^2+ (1-`pun')^2+
> 1)));
  5.                         quietly replace `lnf' = ln((1-`chal')+(`chal')*(1-`pun')) if $ML_y1==0;
  6.                                                                         quietly replace `lnf' = ln((`chal')*(`pun')) if $ML_y1==1;
  7.                 end;

.                 /* Exact replication of Fearon and Laitin 2003 */
> #delimit;
delimiter now ;
.                 logit onset warl gdpenl lpopl lmtnest ncontig Oil nwstate instab polity2l ethfrac relfrac;

Iteration 0:   log likelihood = -538.55615  
Iteration 1:   log likelihood = -500.64979  
Iteration 2:   log likelihood = -483.04494  
Iteration 3:   log likelihood = -480.42625  
Iteration 4:   log likelihood = -480.40167  
Iteration 5:   log likelihood = -480.40166  

Logistic regression                               Number of obs   =       6327
                                                  LR chi2(11)     =     116.31
                                                  Prob > chi2     =     0.0000
Log likelihood = -480.40166                       Pseudo R2       =     0.1080

------------------------------------------------------------------------------
       onset |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        warl |  -.9543723   .3143901    -3.04   0.002    -1.570566   -.3381789
      gdpenl |   -.343856   .0718084    -4.79   0.000    -.4845979   -.2031141
      lpopl1 |   .2629449   .0727147     3.62   0.000     .1204268    .4054631
     lmtnest |   .2188043   .0847523     2.58   0.010     .0526928    .3849158
     ncontig |   .4433291   .2739972     1.62   0.106    -.0936955    .9803537
         Oil |   .8576384   .2791984     3.07   0.002     .3104196    1.404857
     nwstate |   1.709459   .3385988     5.05   0.000     1.045817      2.3731
      instab |   .6175371   .2351006     2.63   0.009     .1567484    1.078326
    polity2l |   .0208624   .0167723     1.24   0.214    -.0120107    .0537356
     ethfrac |   .1664114   .3731063     0.45   0.656    -.5648636    .8976864
     relfrac |     .28505   .5087585     0.56   0.575    -.7120983    1.282198
       _cons |  -6.731338   .7357893    -9.15   0.000    -8.173459   -5.289218
------------------------------------------------------------------------------
Note: 7 failures and 0 successes completely determined.

. gen sample=1 if e(sample)==1;
(283 missing values generated)

. keep if sample==1;
(283 observations deleted)

. /* Replicate Fearon and Laitin 2003 with probit */
> #delimit;
delimiter now ;
. probit onset warl gdpenl lpopl lmtnest ncontig Oil nwstate instab polity2l ethfrac relfrac;

Iteration 0:   log likelihood = -538.55615  
Iteration 1:   log likelihood = -492.70115  
Iteration 2:   log likelihood = -481.97665  
Iteration 3:   log likelihood = -481.42153  
Iteration 4:   log likelihood =  -481.4192  
Iteration 5:   log likelihood =  -481.4192  

Probit regression                                 Number of obs   =       6327
                                                  LR chi2(11)     =     114.27
                                                  Prob > chi2     =     0.0000
Log likelihood =  -481.4192                       Pseudo R2       =     0.1061

------------------------------------------------------------------------------
       onset |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        warl |   -.391057   .1300375    -3.01   0.003    -.6459258   -.1361882
      gdpenl |  -.1350075    .027991    -4.82   0.000    -.1898687   -.0801462
      lpopl1 |   .1076485   .0313018     3.44   0.001     .0462981     .168999
     lmtnest |   .0912107   .0344212     2.65   0.008     .0237464    .1586749
     ncontig |   .1787991   .1215629     1.47   0.141    -.0594598    .4170581
         Oil |   .3519401   .1232808     2.85   0.004     .1103142    .5935659
     nwstate |   .7568601   .1634562     4.63   0.000     .4364919    1.077228
      instab |   .2592462   .1009955     2.57   0.010     .0612987    .4571937
    polity2l |   .0082483   .0070198     1.18   0.240    -.0055102    .0220068
     ethfrac |   .0868783    .157393     0.55   0.581    -.2216062    .3953628
     relfrac |   .1283886   .2088558     0.61   0.539    -.2809612    .5377385
       _cons |  -3.224336   .3034554   -10.63   0.000    -3.819097   -2.629574
------------------------------------------------------------------------------
Note: 22 failures and 0 successes completely determined.

. /*Correct Russia coding error of "4" for onset*/
> recode onset (4=1);
(onset: 1 changes made)

. /*rerun logit replication to show same with Russia recode */
> #delimit;
delimiter now ;
.                 logit onset warl gdpenl lpopl lmtnest ncontig Oil nwstate instab polity2l ethfrac relfrac;

Iteration 0:   log likelihood = -538.55615  
Iteration 1:   log likelihood = -500.64979  
Iteration 2:   log likelihood = -483.04494  
Iteration 3:   log likelihood = -480.42625  
Iteration 4:   log likelihood = -480.40167  
Iteration 5:   log likelihood = -480.40166  

Logistic regression                               Number of obs   =       6327
                                                  LR chi2(11)     =     116.31
                                                  Prob > chi2     =     0.0000
Log likelihood = -480.40166                       Pseudo R2       =     0.1080

------------------------------------------------------------------------------
       onset |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        warl |  -.9543723   .3143901    -3.04   0.002    -1.570566   -.3381789
      gdpenl |   -.343856   .0718084    -4.79   0.000    -.4845979   -.2031141
      lpopl1 |   .2629449   .0727147     3.62   0.000     .1204268    .4054631
     lmtnest |   .2188043   .0847523     2.58   0.010     .0526928    .3849158
     ncontig |   .4433291   .2739972     1.62   0.106    -.0936955    .9803537
         Oil |   .8576384   .2791984     3.07   0.002     .3104196    1.404857
     nwstate |   1.709459   .3385988     5.05   0.000     1.045817      2.3731
      instab |   .6175371   .2351006     2.63   0.009     .1567484    1.078326
    polity2l |   .0208624   .0167723     1.24   0.214    -.0120107    .0537356
     ethfrac |   .1664114   .3731063     0.45   0.656    -.5648636    .8976864
     relfrac |     .28505   .5087585     0.56   0.575    -.7120983    1.282198
       _cons |  -6.731338   .7357893    -9.15   0.000    -8.173459   -5.289218
------------------------------------------------------------------------------
Note: 7 failures and 0 successes completely determined.

. /*rerun probit replication to show same with Russia recode */
> #delimit;
delimiter now ;
. probit onset warl gdpenl lpopl lmtnest ncontig Oil nwstate instab polity2l ethfrac relfrac;

Iteration 0:   log likelihood = -538.55615  
Iteration 1:   log likelihood = -492.70115  
Iteration 2:   log likelihood = -481.97665  
Iteration 3:   log likelihood = -481.42153  
Iteration 4:   log likelihood =  -481.4192  
Iteration 5:   log likelihood =  -481.4192  

Probit regression                                 Number of obs   =       6327
                                                  LR chi2(11)     =     114.27
                                                  Prob > chi2     =     0.0000
Log likelihood =  -481.4192                       Pseudo R2       =     0.1061

------------------------------------------------------------------------------
       onset |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        warl |   -.391057   .1300375    -3.01   0.003    -.6459258   -.1361882
      gdpenl |  -.1350075    .027991    -4.82   0.000    -.1898687   -.0801462
      lpopl1 |   .1076485   .0313018     3.44   0.001     .0462981     .168999
     lmtnest |   .0912107   .0344212     2.65   0.008     .0237464    .1586749
     ncontig |   .1787991   .1215629     1.47   0.141    -.0594598    .4170581
         Oil |   .3519401   .1232808     2.85   0.004     .1103142    .5935659
     nwstate |   .7568601   .1634562     4.63   0.000     .4364919    1.077228
      instab |   .2592462   .1009955     2.57   0.010     .0612987    .4571937
    polity2l |   .0082483   .0070198     1.18   0.240    -.0055102    .0220068
     ethfrac |   .0868783    .157393     0.55   0.581    -.2216062    .3953628
     relfrac |   .1283886   .2088558     0.61   0.539    -.2809612    .5377385
       _cons |  -3.224336   .3034554   -10.63   0.000    -3.819097   -2.629574
------------------------------------------------------------------------------
Note: 22 failures and 0 successes completely determined.

. matrix P_cw = e(b);

. matrix P_cw_se = e(V);

. matrix ll_p = e(ll);

. /* Model comparison */
> /* Generate individual likelihoods for Clarke's nonparametric test (with correction for number of parameters)*/
>                 gen double lnfj_p = .;
(6327 missing values generated)

.                         replace lnfj_p = ln(normal(-(_b[gdpenl]*gdpenl + _b[lpopl]*lpopl + _b[lmtnest]*lmtnest + _b[ncontig]*ncontig
>                                 + _b[Oil]*Oil + _b[nwstate]*nwstate + _b[instab]*instab + _b[polity2l]*polity2l + _b[ethfrac]*ethfrac + _b[relfrac]*relfrac + _b[_con
> s]))) if onset==0;
(6221 real changes made)

.                         replace lnfj_p = ln(normal((_b[gdpenl]*gdpenl + _b[lpopl]*lpopl + _b[lmtnest]*lmtnest + _b[ncontig]*ncontig
>                                 + _b[Oil]*Oil + _b[nwstate]*nwstate + _b[instab]*instab + _b[polity2l]*polity2l + _b[ethfrac]*ethfrac + _b[relfrac]*relfrac + _b[_con
> s]))) if onset==1;
(106 real changes made)

.                         replace lnfj_p = lnfj_p*(12/(2*_N))*ln(_N);
(6323 real changes made)

.                 /* probability of war (probit) */
>                 gen double pr_War_p = normal(_b[gdpenl]*gdpenl + _b[lpopl]*lpopl + _b[lmtnest]*lmtnest + _b[ncontig]*ncontig
>                                 + _b[Oil]*Oil + _b[nwstate]*nwstate + _b[instab]*instab + _b[polity2l]*polity2l + _b[ethfrac]*ethfrac + _b[relfrac]*relfrac + _b[_con
> s]);

.                 gen p_predict_War = 0 if sample==1;

.                                 replace p_predict_War =1 if pr_War_p > .5;
(0 real changes made)

.                         /* observations correctly predicted */  
>                         gen correct_p = 0 if sample==1;

.                                 replace correct_p = 1 if (p_predict_War==1 & onset==1) | (p_predict_War==0 & onset==0);
(6221 real changes made)

.                         /* observations correctly predicted as war */
>                         gen correct_war_p = .;
(6327 missing values generated)

.                                 replace correct_war_p = 0 if (p_predict_War==0 & onset==1);
(106 real changes made)

.                                 replace correct_war_p = 1 if (p_predict_War==1 & onset==1);
(0 real changes made)

.                         /* observations incorrectly predicted as war*/
>                         gen incorrect_war_p =.;
(6327 missing values generated)

.                                 replace incorrect_war_p = 0 if (p_predict_War==0 & onset==0);
(6221 real changes made)

.                                 replace incorrect_war_p = 1 if (p_predict_War==1 & onset==0);
(0 real changes made)

.                                         /* results*/
>                         sum correct_p correct_war_p incorrect_war_p;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
   correct_p |      6327    .9832464     .128357          0          1
correct_wa~p |       106           0           0          0          0
incorrect_~p |      6221           0           0          0          0

.                         /* Strategic Probit with Partial Observability */
>         /* run second stage model to find initial conditions (following Bas, Signorino, and Walker (2008)'s strategic backwards induction logic) */ 
>         #delimit;
delimiter now ;
.         probit onset  gdpenl Oil nwstate instab ncontig warl;

Iteration 0:   log likelihood = -538.55615  
Iteration 1:   log likelihood = -504.00874  
Iteration 2:   log likelihood = -494.36682  
Iteration 3:   log likelihood = -493.95628  
Iteration 4:   log likelihood = -493.95449  
Iteration 5:   log likelihood = -493.95449  

Probit regression                                 Number of obs   =       6327
                                                  LR chi2(6)      =      89.20
                                                  Prob > chi2     =     0.0000
Log likelihood = -493.95449                       Pseudo R2       =     0.0828

------------------------------------------------------------------------------
       onset |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      gdpenl |   -.134325   .0255629    -5.25   0.000    -.1844274   -.0842226
         Oil |   .3300587   .1152771     2.86   0.004     .1041198    .5559976
     nwstate |   .6919491   .1569787     4.41   0.000     .3842765    .9996217
      instab |   .2786737   .0988109     2.82   0.005      .085008    .4723394
     ncontig |   .3774159   .1095145     3.45   0.001     .1627715    .5920603
        warl |  -.2579579   .1260235    -2.05   0.041    -.5049595   -.0109564
       _cons |  -1.982881   .0724082   -27.38   0.000    -2.124799   -1.840963
------------------------------------------------------------------------------
Note: 16 failures and 0 successes completely determined.

.         matrix B2 = e(b);

.         predict pr;
(option pr assumed; Pr(onset))

.         gen prT = normal(pr);

.         /* run first stage model to find initial conditions (following Bas, Signorino, and Walker (2008)'s strategic backwards induction logic) */
>         gen Ngdpenl = -gdpenl;

.         gen Npolity2l = -polity2l;

.         gen Ncons_11 = -1;

.         gen Ninstab = -instab;

.         gen Tlpopl = prT*lpopl;

.         gen Tlmtnest = prT*lmtnest;

.         gen TOil = prT*Oil;

.         gen Tethfrac = prT*ethfrac;

.         gen Trelfrac = prT*relfrac;

.         gen Twarl = prT*warl;

.                 probit onset Ngdpenl Npolity2l Ninstab Ncons_11  Tlpopl Tlmtnest TOil Tethfrac Trelfrac Twarl, nocons;

Iteration 0:   log likelihood = -4385.5422  
Iteration 1:   log likelihood = -529.53711  
Iteration 2:   log likelihood = -494.65906  
Iteration 3:   log likelihood = -489.12454  
Iteration 4:   log likelihood = -488.96716  
Iteration 5:   log likelihood = -488.96704  
Iteration 6:   log likelihood = -488.96704  

Probit regression                                 Number of obs   =       6327
                                                  Wald chi2(10)   =    2434.69
Log likelihood = -488.96704                       Prob > chi2     =     0.0000

------------------------------------------------------------------------------
       onset |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     Ngdpenl |   .1348292   .0275645     4.89   0.000     .0808039    .1888546
   Npolity2l |  -.0129556   .0067142    -1.93   0.054    -.0261152    .0002039
     Ninstab |  -.1770565   .0996571    -1.78   0.076    -.3723809    .0182678
    Ncons_11 |   3.289595   .2844845    11.56   0.000     2.732016    3.847174
      Tlpopl |   .2360093   .0561856     4.20   0.000     .1258875    .3461311
    Tlmtnest |   .1860726     .06685     2.78   0.005     .0550491    .3170962
        TOil |   .7189952   .2332404     3.08   0.002     .2618524    1.176138
    Tethfrac |   .2301191   .3044607     0.76   0.450     -.366613    .8268512
    Trelfrac |   .3523452   .4074004     0.86   0.387    -.4461449    1.150835
       Twarl |  -.7719618   .2482779    -3.11   0.002    -1.258577   -.2853462
------------------------------------------------------------------------------
Note: 22 failures and 0 successes completely determined.

.         matrix B1 = e(b);

.                 /* Maximize the model */ 
>         #delimit;
delimiter now ;
.         ml model lf sppo_lf 
>                 (R_SQ:onset= gdpenl polity2l instab) 
>                 (R_War:onset=  lpopl lmtnest Oil ethfrac relfrac warl, nocons)
>                 (R_Acq: onset=)
>                 (G_War:onset=  gdpenl Oil nwstate instab ncontig warl) ;

.         ml check;

Test 1:  Calling sppo_lf to check if it computes log likelihood and
         does not alter coefficient vector...
         Passed.

Test 2:  Calling sppo_lf again to check if the same log likelihood value is
         returned...
         Passed.

Test 3:  Calling sppo_lf to check if 1st derivatives are computed...
         test not relevant for type lf evaluators.

Test 4:  Calling sppo_lf again to check if the same 1st derivatives are
         returned...
         test not relevant for type lf evaluators.

Test 5:  Calling sppo_lf to check if 2nd derivatives are computed...
         test not relevant for type lf evaluators.

Test 6:  Calling sppo_lf again to check if the same 2nd derivatives are
         returned...
         test not relevant for type lf evaluators.

------------------------------------------------------------------------------
Searching for alternate values for the coefficient vector to verify that
sppo_lf returns different results when fed a different coefficient vector:

Searching...
initial:       log likelihood =     -<inf>  (could not be evaluated)
searching for feasible values +

feasible:      log likelihood = -4963.5971
improving initial values +.........
improve:       log likelihood =  -1190.287

continuing with tests...
------------------------------------------------------------------------------

Test 7:  Calling sppo_lf to check log likelihood at the new values...
         Passed.

Test 8:  Calling sppo_lf requesting 1st derivatives at the new values...
         test not relevant for type lf evaluators.

Test 9:  Calling sppo_lf requesting 2nd derivatives at the new values...
         test not relevant for type lf evaluators.

------------------------------------------------------------------------------
                         sppo_lf HAS PASSED ALL TESTS
------------------------------------------------------------------------------

Test 10: Does sppo_lf produce unanticipated output?
         This is a minor issue.  Stata has been running sppo_lf with all
         output suppressed.  This time Stata will not suppress the output.  If
         you see any unanticipated output, you need to place quietly in front
         of some of the commands in sppo_lf.

-------------------------------------------------------------- begin execution
---------------------------------------------------------------- end execution

.         ml init B1 0 B2 , copy ;

.         ml maximize,  diff;

initial:       log likelihood =  -761.9184
rescale:       log likelihood = -515.82993
rescale eq:    log likelihood = -511.18521
Iteration 0:   log likelihood = -511.18521  (not concave)
Iteration 1:   log likelihood = -496.32324  (not concave)
Iteration 2:   log likelihood = -489.04564  (not concave)
Iteration 3:   log likelihood = -483.79104  (not concave)
Iteration 4:   log likelihood =  -480.3493  (not concave)
Iteration 5:   log likelihood = -479.51885  (not concave)
Iteration 6:   log likelihood = -479.01902  (not concave)
Iteration 7:   log likelihood = -478.04686  
Iteration 8:   log likelihood = -478.01562  
Iteration 9:   log likelihood = -477.90525  (not concave)
Iteration 10:  log likelihood = -477.89479  
Iteration 11:  log likelihood =  -477.8885  
Iteration 12:  log likelihood = -477.85309  
Iteration 13:  log likelihood = -477.85066  
Iteration 14:  log likelihood = -477.84945  
Iteration 15:  log likelihood = -477.84942  

                                                  Number of obs   =       6327
                                                  Wald chi2(3)    =      11.37
Log likelihood = -477.84942                       Prob > chi2     =     0.0099

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
R_SQ         |
      gdpenl |   .2076859   .0667534     3.11   0.002     .0768515    .3385202
    polity2l |  -.0118872   .0104067    -1.14   0.253    -.0322839    .0085095
      instab |  -.2195339   .2728795    -0.80   0.421    -.7543679       .3153
       _cons |   6.246977    1.86498     3.35   0.001     2.591683    9.902272
-------------+----------------------------------------------------------------
R_War        |
      lpopl1 |   .4132725    .224451     1.84   0.066    -.0266434    .8531884
     lmtnest |   .3133189   .1748277     1.79   0.073    -.0293371    .6559748
         Oil |   1.467188   1.021622     1.44   0.151    -.5351534     3.46953
     ethfrac |   .3082676   .6160185     0.50   0.617    -.8991065    1.515642
     relfrac |   .2716171   .7513775     0.36   0.718    -1.201056     1.74429
        warl |  -1.682225   .9895458    -1.70   0.089      -3.6217    .2572488
-------------+----------------------------------------------------------------
R_Acq        |
       _cons |   4.474358   2.001151     2.24   0.025     .5521742    8.396542
-------------+----------------------------------------------------------------
G_War        |
      gdpenl |   .0220794   .1187996     0.19   0.853    -.2107635    .2549224
         Oil |  -.0984345    .468056    -0.21   0.833    -1.015807    .8189384
     nwstate |   2.515823   3.173712     0.79   0.428    -3.704539    8.736185
      instab |   .3420697   .4599146     0.74   0.457    -.5593463    1.243486
     ncontig |   .4997341   .3929355     1.27   0.203    -.2704053    1.269874
        warl |   .2734912   .6195484     0.44   0.659    -.9408013    1.487784
       _cons |  -.7681555   .5249982    -1.46   0.143    -1.797133    .2608222
------------------------------------------------------------------------------

.                 matrix beta_cw = e(b);

.         matrix se_cw = e(V);

.         matrix ll_sppo = e(ll);

.                         /* Model comparison */
>         /* Generate individual likelihoods for Clarke's nonparametric test (with correction for number of parameters)*/
>         gen double pun = normal( ([G_War]_b[gdpenl]*gdpenl + [G_War]_b[Oil]*Oil 
>                         + [G_War]_b[nwstate]*nwstate + [G_War]_b[instab]*instab + [G_War]_b[ncontig]*ncontig 
>                         + [G_War]_b[warl]*warl + [G_War]_b[_cons]*1) / sqrt(2) );

.                 gen double chal = normal( 
>                         ( pun*([R_War]_b[lpopl]*lpopl + [R_War]_b[lmtnest]*lmtnest + [R_War]_b[Oil]*Oil 
>                                         + [R_War]_b[ethfrac]*ethfrac + [R_War]_b[relfrac]*relfrac + [R_War]_b[warl]*warl)
>                         + (1-pun)*([R_Acq]_b[_cons])
>                         - ([R_SQ]_b[gdpenl]*gdpenl + [R_SQ]_b[polity2l]*polity2l + [R_SQ]_b[instab]*instab + [R_SQ]_b[_cons]) ) 
>                         /(sqrt(pun^2+ (1-pun)^2+1) ));

.                 gen double lnfj_sppo = .;
(6327 missing values generated)

.                         replace  lnfj_sppo = ln((1-chal)+(chal)*(1-pun)) if onset==0;
(6221 real changes made)

.                         replace  lnfj_sppo = ln((chal)*(pun)) if onset==1;
(106 real changes made)

.                         #delimit;
delimiter now ;
.                         replace lnfj_sppo = lnfj_sppo*(18/(2*_N))*ln(_N);
(6320 real changes made)

.                 #delimit;
delimiter now ;
.                 /* probability of war (sppo) */
>                 gen double pr_War_sppo = pun*chal;

.                 gen double pr_Acq_sppo = chal*(1-pun);

.                 gen double pr_Det_sppo = 1-chal;

.                         gen sppo_predict_War = 0 if sample==1;

.                                 replace sppo_predict_War =1 if (pr_War_sppo > pr_Acq_sppo) & (pr_War_sppo > pr_Det_sppo);
(2 real changes made)

.                         /* observations correctly predicted */
>                         gen correct_sppo = 0 if sample==1;

.                                 replace correct_sppo = 1 if (sppo_predict_War==1 & onset==1) | (sppo_predict_War==0 & onset==0);
(6221 real changes made)

.                         /* observations correctly predicted as war*/
>                         gen correct_war_sppo = .;
(6327 missing values generated)

.                                 replace correct_war_sppo = 0 if (sppo_predict_War==0 & onset==1);
(105 real changes made)

.                                 replace correct_war_sppo = 1 if (sppo_predict_War==1 & onset==1);
(1 real change made)

.                         /* observations incorrectly predicted as war*/
>                         gen incorrect_war_sppo =.;
(6327 missing values generated)

.                                 replace incorrect_war_sppo = 0 if (sppo_predict_War==0 & onset==0);
(6220 real changes made)

.                                 replace incorrect_war_sppo = 1 if (sppo_predict_War==1 & onset==0);
(1 real change made)

.                                                         /* results*/
>                         sum correct_sppo correct_war_sppo incorrect_war_sppo;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
correct_sppo |      6327    .9832464     .128357          0          1
correct_wa~o |       106     .009434    .0971286          0          1
incorrect_~o |      6221    .0001607    .0126786          0          1

.                                                                 /* Clarke Test */
>         signtest lnfj_p=lnfj_sppo;

Sign test

        sign |    observed    expected
-------------+------------------------
    positive |        5090      3161.5
    negative |        1233      3161.5
        zero |           4           4
-------------+------------------------
         all |        6327        6327

One-sided tests:
  Ho: median of lnfj_p - lnfj_sppo = 0 vs.
  Ha: median of lnfj_p - lnfj_sppo > 0
      Pr(#positive >= 5090) =
         Binomial(n = 6323, x >= 5090, p = 0.5) =  0.0000

  Ho: median of lnfj_p - lnfj_sppo = 0 vs.
  Ha: median of lnfj_p - lnfj_sppo < 0
      Pr(#negative >= 1233) =
         Binomial(n = 6323, x >= 1233, p = 0.5) =  1.0000

Two-sided test:
  Ho: median of lnfj_p - lnfj_sppo = 0 vs.
  Ha: median of lnfj_p - lnfj_sppo != 0
      Pr(#positive >= 5090 or #negative >= 5090) =
         min(1, 2*Binomial(n = 6323, x >= 5090, p = 0.5)) =  0.0000

.         /* Voung Test*/
>         svmat ll_p;

.         svmat ll_sppo;

.         gen num_V = ll_p1 - ll_sppo1 + ((12/2)*ln(_N)-(18/2)*ln(_N));
(6326 missing values generated)

.         egen denom1_V = mean((lnfj_p/lnfj_sppo)^2);

.         gen denom2_V = sqrt(denom1_V);

.         gen Voung = num_V/denom2_V;
(6326 missing values generated)

.         sum num_V denom2_V Voung;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       num_V |         1   -29.82751           .  -29.82751  -29.82751
    denom2_V |      6327    12.53565           0   12.53565   12.53565
       Voung |         1   -2.379415           .  -2.379415  -2.379415

. /* Generate predicted probabilities */
> collapse (mean) polity2l  lmtnest lpopl ethfrac relfrac
>         (median) ncontig nwstate  warl
>         (max)  Oil     instab
>         (min) gdpenl_p5 = gdpenl (p92) gdpenl_p95= gdpenl;

.                 expand 100;
(99 observations created)

.         gen gdpenl = gdpenl_p5 + (gdpenl_p95 - gdpenl_p5)*(_n-1)/_N;

.         expand 100;
(9900 observations created)

.                 #delimit;
delimiter now ;
. /* SPPO xbhat */
> drawnorm R_SQ_B1 R_SQ_B2 SQ_B3 R_SQ_B0 
>                  R_War_B1 R_War_B2 R_War_B3 R_War_B4 R_War_B5 R_War_B6 
>                  R_Acq_B0
>                  G_War_B1 G_War_B2 G_War_B3 G_War_B4 G_War_B5 G_War_B6 G_War_B0,
>         means(beta_cw) cov(se_cw);

.         gen double xbhat_R_SQ = R_SQ_B1*gdpenl + R_SQ_B2*polity2l + SQ_B3*instab + R_SQ_B0;

. gen double xbhat_R_War = R_War_B1*lpopl + R_War_B2*lmtnest + R_War_B3*Oil + R_War_B4*ethfrac + R_War_B5*relfrac 
>                                                         + R_War_B6*warl;

. gen double xbhat_R_Acq = R_Acq_B0;

. gen double xbhat_G_War = G_War_B1*gdpenl + G_War_B2*Oil + G_War_B3*nwstate + G_War_B4*instab 
>                                                         + G_War_B5*ncontig + G_War_B6*warl + G_War_B0;

. /* Probit xbhat */
> drawnorm B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B0, means(P_cw) cov(P_cw_se);

. gen double xbhat_probit = B1*warl + B2*gdpenl + B3*lpopl + B4*lmtnest + B5*ncontig + B6*Oil + B7*nwstate + B8*instab 
>                                                 + B9*polity2l + B10*ethfrac + B11*relfrac + B0;

. /* collapse and compare SPPO and probit predicted probabilities*/                                                       
> collapse xbhat_R_SQ     xbhat_R_War     xbhat_R_Acq     xbhat_G_War xbhat_probit, by(gdpenl);

.                                                                                         gen double pr_pun = normal(xbhat_G_War/sqrt(2));

. gen double pr_chal = normal((pr_pun*xbhat_R_War+(1-pr_pun)*xbhat_R_Acq-xbhat_R_SQ)/sqrt(pr_pun^2+ (1-pr_pun)^2+1));

.         gen double pr_War = pr_pun*pr_chal;

. gen double pr_Acq = pr_chal*(1-pr_pun);

. gen double pr_Det = 1-pr_chal;

. gen prop_War = pr_War / pr_chal;

. gen prop_Acq = pr_Acq / pr_chal;

. gen pr_War_probit = normal(xbhat_probit);

.                 /* Graph the results */
>                 #delimit;
delimiter now ;
.                 twoway lowess pr_War_probit gdpenl, sort lpattern(solid) ||
>                                 lowess pr_chal gdpenl, sort lpattern(dash) lwidth(medthick) lcolor(gs0) ||
>                                 lowess pr_War gdpenl,  sort lpattern(longdash_dot) lwidth(medthick) ||
>                                 lowess pr_Acq gdpenl,  sort lpattern(shortdash) lwidth(medthick)
>                                 scheme(s1mono) 
>                                 title("Probabilities for All Outcomes")
>                                 ytitle("Pr(Outcome)")
>                                 xtitle("GDP per Capita (in thousands)") 
>                                 legend(lab(1 "War (Probit)") lab(2 "Challenge (SPPO)") lab(3 "War (SPPO)") lab(4 "Gov. Acquiesce (SPPO)"))
>                                 note("Note: Predicted probabilities are for oil exporting and experienced recent political instability." 
>                                      "All other variables held at mean or median. ''SPPO'' indicates Strategic Probit with Partial"
>                                          "Observability.");

.                                          graph save F&L_War, asis replace;
(note: file F&L_War.gph not found)
file F&L_War.gph saved

.                                          graph export F&L_War.eps, replace;
(note: file F&L_War.eps not found)
(file F&L_War.eps written in EPS format)

. 
end of do-file

. exit, clear
